/*
 * @Author: Y先森
 * @Date: 2023-04-28 14:42:39
 * @LastEditors: y && 250048395@qq.com
 * @LastEditTime: 2023-04-28 15:22:50
 * @FilePath: \y-website\src\libs\message\index.js
 */
import { h, render } from 'vue'
import messageComponent from './index.vue'
/**
 * 
 * @param {*} type 类型:success
 * @param {*} content 内容描述
 * @param {*} duration 展示时长 默认 3000毫秒
 */
export const message = (type,content,duration = 3000 )=>{
    /**
     * 动画结束时的回调
     */
    const onDestroy = () =>{
        // 3. 删除 render
        render(null, document.body)
    }
    // 1. 拿到 vnode
    const vnode = h(messageComponent,{
        type,content,duration,destroy:onDestroy
    })
    // 2. render渲染 vnode
    render(vnode, document.body)
}